65 questions
1
vote
0
answers
235
views
Nextjs 14 dynamic import script ERROR: Cannot find module
With Nextjs 14 i'm trying to create a component that can switch the running script depending on a prop that is passed:
TLDR. I'm not trying to import a component or a node_module, this is an external ...
1
vote
3
answers
1k
views
Using Query to select column based on the headers
I have a dynamic table where columns are moved every now and then. Therefore, I would like to reference my column name in my query. Unfortunately I do not know so well and the internet raises more ...
2
votes
1
answer
258
views
How to load CSS file in qooxdoo dynamically
Is there a special qooxdoo class to load CSS files dynamically like qx.util.DynamicScriptLoader does for JavaScript files?
For example, depends on user choice what geo maps he wants to use an ...
0
votes
0
answers
265
views
Load External Script dynamically in Angular 8
I have built an application that loads articles into a page component using an api from our server. The article loads correctly. Where I am having a problem is I have an embedded script in the api ...
0
votes
1
answer
81
views
JavaScript : Can anyone give an example when callback in callback (Pyramid of Doom) is needed?
The below code does callback inside a callback. Why this is needed? Why can't it be 3 separate calls? Note loadScript just going to create a style tag and add script passed to the src attribute ...
1
vote
1
answer
1k
views
Is there any useful mime for <script type="mime" src="..."> except for JS?
From much reading I conclude:
The <script> tag can store data, but it is only accessible if src is not used.
I want to use src because it is how my script-loader works.
Is the type attribute ...
0
votes
1
answer
184
views
Adding external library to my Angular 6 project only works when I'm running in localhost
I dynamically added the Chrome Api Library (from https://www.gstatic.com/cv/js/sender/v1/cast_sender.js) to my project, and works as expected when I run using localhost:4200. However it doesn't work ...
-16
votes
2
answers
645
views
How to Garbage Collect an external Javascript load?
Given a loader:
function loader(src, callback, fail) {
let s = document.head.appendChild(document.createElement('script'));
s.type = "text/javascript";
s.src = src;
s.onload = ...
0
votes
0
answers
40
views
How to lazily load components from another host?
How to lazily load components from another host in Angular?
Hello guys. I have a problem with Angular. My web application is deployed on a certain server(e.g. http://www.a.com), and my javascript ...
4
votes
1
answer
8k
views
Dynamically Script Loading Zendesk Widget
I have been trying to save resources on the page by not loading the Zendesk Widget unless required.
If i manually add to a page the following tag everything works just fine:
<script id="ze-...
0
votes
0
answers
413
views
Why does Vue not initialize when loaded via a script-loader?
I need to load VueJS dynamically using a script loader but I'm unable to understand why Vue doesn't initialize.
Here's my simple script-loader:
(function( w ){
var loadJS = function( src, cb ){
...
0
votes
2
answers
231
views
I have loading iframe by adding scripts dynamically. But getting a Reference error as $ is not defined
I'm calling the function after adding the jquery script. but still, I'm getting a Reference error
<script>
window.onload = function(){
AddScript("https://cdn.syncfusion.com/js/...
0
votes
1
answer
175
views
How to dynamically add scripts tag at each Sub-domain level through single angular application?
I have tired some of DOM operation like,
document.createElement
document.write
The document.createElement way requires a standard script structure . But in my case it can be either a java ...
2
votes
2
answers
6k
views
Immediately execute dynamically loaded JS script
at the top of the head of my document I dynamically load a script:
<script>
var script = document.createElement("script");
script.setAttribute("src", "mydomain.com/main.js");
var head = ...
0
votes
1
answer
2k
views
Insert dynamic onClick event script in Google Optimize
I need to add a html element, a button, trough the Google Optimize experiment and it has to perform a certain script depending on the experiment.
I have tried to do it in the following ways:
<...
0
votes
1
answer
161
views
Does this Funnelytics code contain a race condition?
I'm looking into tracking scripts that I've come across. Here's one by Funnelytics. At first look it seems like it has a bug:
(function(funnel) {
var insert = document.getElementsByTagName('...
0
votes
0
answers
269
views
Dynamic scripts in android
My Scenario
Suppose my android activity has a screen like this:
All the fields are populated according to a response received from API.
In the above scenario, the API response told to insert
One ...
6
votes
0
answers
1k
views
DOMContentLoaded and turbolinks:load not triggering on Dynamically loaded scripts with first page load (loaded without turbolinks)
'turbolinks:load' is not getting triggered on the directly loaded pages but, on the pages loaded with turbolinks 'turbolinks:load' event is working fine.
<!DOCTYPE html>
<html>
<...
7
votes
1
answer
6k
views
Using Spotify Web Playback SDK with React
Spotify has a new feature in beta supporting full song playback in browser, Web Playback SDK. The documentation shows an example of immediately initializing a player using script tags in the main HTML ...
8
votes
4
answers
2k
views
How to circumvent RequireJS to load module with global?
I'm trying to load a JS file from a bookmarklet. The JS file has this JS that wraps the module:
(function (root, factory) {
if (typeof module === 'object' && module.exports) {
// ...
0
votes
1
answer
344
views
Javascript: Dynamically added script can't find previously defined function in another script
I'm having what seems to be a really simple issue that I really can't find a solution for:
In my code I have a script loaded in the header:
<script type="text/javascript" src="../js/viewdoc/index....
0
votes
2
answers
746
views
How can I get the line-number of an error in a dynamically added <script> tag?
When dynamically creating a script element and adding it to the page, my errors are not giving me line numbers of the script, but instead the line number where I append the script.
The code below ...
1
vote
1
answer
103
views
Configure SystemJS to always return same instance of library
I have two jspm modules, ModuleA and ModuleB. Both depend on the d3.js library. I have a third jspm module, ModuleC, which depends on ModuleA and ModuleB. When I run ModuleC, I get d3 errors, even ...
0
votes
0
answers
37
views
How does script loading work when it adds scripts to code that already has been executed?
I'm trying to wrap my mind around script loading from this website but don't understand the part about how appending a child to the head for the script will make a script accessible on demand. The ...
1
vote
2
answers
4k
views
Is it possible to load javascript files without executing them [duplicate]
Is it possible to load a javascript file in a browser (e.g. from some javascript code) without the loaded code being executed?
The goal would be to just download the javascript file to ensure that ...
-1
votes
2
answers
2k
views
Load JS script from file system and execute it with selenium
I'm truing to execute a yui js script with js.executeScript Selenium's method.
The script is being executed by selenium webdriver in order simulate a "click" on hybrid mobile app (the button is ...
0
votes
1
answer
338
views
Extending Angular function to execute script on JSON dynamically
I am designing a platform for a site, where site users are allowed to execute scripts on JSON in browser window only
Here is a screen shot of page:
user will be getting the JSON, and whatever script ...
18
votes
1
answer
6k
views
Why script elements created through DOMParser do not execute?
I'm loading HTML in Ajax, parsing it with DOMParser and put all the childNodes of the document body into a document fragment.
When I add the fragment into the current document's body, <script> ...
8
votes
2
answers
3k
views
Efficiency of Browserify with multiple bundles
I'm new to Browserify and I'm trying to figure out how to make it more efficient with regards to how much the client needs to download.
I have a web app, that uses many different 3rd party libraries ...
0
votes
1
answer
61
views
Is dynamic script execution order still unreliable in IE if files are loaded locally?
If I load a number of JavaScript files dynamically using code such as:
element = document.createElement("script");
element.setAttribute("language", "javascript");
element.setAttribute("src", url);
...
2
votes
2
answers
2k
views
using global for dependency with grunt-browserify
I'm using yepnope to load scripts conditionally, based on some tests, and I'm also using browserify, via grunt-browserify to build my scripts. Now I want one script to replace the other, but still be ...
11
votes
2
answers
16k
views
Dynamically load Web Components / HTML Imports?
How would you go about dynamically loading a web component - in response to a url route change for example?
I won't know the requested component ahead of time, so could you simply use JavaScript to ...
1
vote
0
answers
121
views
Prevent memory leak from repeated $.ajax( { dataType : 'script' } )
I'm writing a little locally-run web app that expects to have intermittent network access. With this in mind I'm checking to see if our external dependency (Google Maps) fails to load, and try again ...
0
votes
0
answers
474
views
executing function as needed in jquery mobile in multiple pages
I'm having a difficult time wrapping my head around this issue, and I'm hoping some of you can shed some light on this for me.
I have seen plenty of questions being asked which center around ...
1
vote
1
answer
384
views
Loading two script blocks (using lab.js as a load manager)
I'm trying to load two blocks of lab.js in different places but if I use functions in the second block from files loaded in the first block, they show as undefined.
This is the first block (loaded in ...
1
vote
1
answer
2k
views
Page speed - any problems with simply using defer attribute?
Google recommends scripts should be "deferred", but they do not mention the defer attribute of the <script> tag. I wonder why they don't even mention it, considering it has been around a while.
...
4
votes
2
answers
386
views
Better management of Javascript and html template files: Edit as many files, but use as one file
Background
Have a project that includes over 100 Javascript and HTML template files. Using a script loader (yepnope) that loads the files directly from our development environment so that during the ...
1
vote
1
answer
1k
views
Require.js -- how to load relative to a module directory
My structure looks like so:
index.html
main.js #holds the configs.path and configs.shim
libs
jquery.js
require.js
backbone.js
underscore.js
modules
app
main.js #want to load in ./views/app.js ...
1
vote
1
answer
120
views
"is" operator exhibiting unexpected behavior in IronPython scripts
Using the advice in the answers to this question, I created a new type (_NotInFile) and singleton instance (NotInFile) to represent a special condition in a series of IronPython scripts. I tested my ...
17
votes
3
answers
5k
views
Wrapper to allow a module to work with AMD/CommonJs or script tags?
I just took a shot at wrapping one of our modules that is meant to be included via a <script> tag in some boilerplate to allow optional AMD loading with requirejs.
It was quite painful and the ...
0
votes
1
answer
497
views
How to make a fallback to a whole folder in requireJS
I understood how I can config in requireJS a fallback for a single file like this:
var skin = "christmas";
requirejs.config({
paths: {
languagesLocal : [
BaseUrl + ...
11
votes
3
answers
4k
views
How to mixin Underscore plugins in RequireJS?
What is the right way to execute code on Underscore when it gets loaded? I am trying to execute the below code to extend the _ exported namespace automatically when modules require it:
_.mixin(_.str....
1
vote
3
answers
411
views
jQuery: Update jQuery-version on the fly via $.getScript
If you are in an environment that starts out with jQuery 1.7.x, are there any risks to run $.getScript and load the latest version of jQuery (1.8.3)?
Will it overwrite the updated functions correctly ...
1
vote
1
answer
1k
views
Injecting a script to page with callback
I'm trying to inject yepnope.js to page and then loading other JS files with yepnope.
Chrome Dev Tools' network tab shows yepnope is fetched, elements tab show element is injected. But console tab ...
6
votes
3
answers
3k
views
How to check if an asynchronously loaded script has finished loading in javascript
Using javascript to asynchronously download another javascript file.
I understand that this can be done by inserting a new script tag onto the page with the src attribute set to the file url.
I also ...
0
votes
1
answer
421
views
Force a script refresh using the "yepnope" JavaScript script loader
Using yepnope.js. I need to "refresh" the script, but yepnope prevents files with the same url from being re-loaded.
In the documentation, they suggest using a plugin to allow files to refresh. Is ...
0
votes
3
answers
791
views
How to pass returned public object from loaded JavaScript file into callback function?
I have a JavaScript file, which returns public methods. This JavaScript file I am not loading at the beginning, but preloading only when it's needed. Example:
(function () {
// Some privat vars and ...
0
votes
1
answer
260
views
displaying progress bar for labjs, labjs callbacks
How can I keep track of what scripts have been loaded so far so I can display a progress bar when using labjs (http://labjs.com/)? wait() doesn't work because then it won't parallel load the next ...
-2
votes
2
answers
302
views
JavaScript: Dynamic Script Loading without manipulating the DOM?
How do I add an external JavaScript(-library) to a page through JavaScript-code without:
Manipulating the DOM
Preferably without using Eval?
That means adding a script-tag through JavaScript is not ...
3
votes
1
answer
874
views
Modernizr/ yepnope execution order WRT jQuery + plugins troubleshooting
I'm getting my head around Modernizr polyfill loading today and running into some trouble. I like the idea of loading jQuery in parallell and so have the CDN URI (with a local fallback) up top. Then I ...