Advertisement
plirof2

Javascript - load script dynamically and execute it

Jan 11th, 2024
1,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             // Load Javascript dynamically
  2.             if (autonumberlinks) {
  3.               var secondScript = document.createElement('script');
  4.               secondScript.type = 'text/javascript';
  5.               secondScript.src = 'test_hash.js';
  6.                 secondScript.onload = function() {
  7.                 // code to execute after the second script is loaded and executed
  8.                 addHashLabels(); // function of the dynamic loaded file
  9.               };
  10.               document.head.appendChild(secondScript);
  11.             }                        
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement