Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
0 answers
231 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 ...
Lefan's user avatar
  • 11
0 votes
1 answer
78 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 ...
AjithKumar's user avatar
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 ...
user avatar
-16 votes
2 answers
642 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 = ...
user avatar
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-...
Victor Albu's user avatar
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 ){ ...
Mridang Agarwalla's user avatar
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/...
vinoth-kumar-s's user avatar
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 = ...
Andre Brdoch's user avatar
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: <...
Zerg's user avatar
  • 819
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('...
Flimm's user avatar
  • 153k
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> <...
Satyendra Tiwari's user avatar
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 ...
bitwitch's user avatar
  • 515
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) { // ...
Web_Designer's user avatar
0 votes
1 answer
342 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....
Ricardo Melo's user avatar
0 votes
2 answers
740 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 ...
Seph Reed's user avatar
  • 11.4k

15 30 50 per page