Hidden JS Libaries

Hi There

this is just a quick note to let you know why I had a hard time with AnyMod today:

I was realizing much too late there actually is an external JS-SAsset added to that MOD!

Thus I was wondering why some JS Functions no longer aplied after I relocated the JS Code outside of the MOD (which is sth I had to do for other reasons).

I stumbled upon that sort of problem several times lately.

I feel I would love to have a small counter ICON
to visualize the number of JS and CSS libaries the MOD is making use of:
see screenshot:

JS ASSET WAS NOT SEEN THUS I HAD A HARD TIME FOR A LONG TIME

PS: I was working with jquery’s Document ready function today. I found out the Anymod-HTML was rendered to the dom LATER than the Document ready function fiered. I did not expect that . thus jquery loaded some functions earier than the content was available. ( This PS is nothing but an off-topic-comment not related to the issue described above )

1 Like

This is a great suggestion – thank you!

Currently the indicator is on the JS bar (middle right of your screenshot), but it would make more sense to have it where you have suggested.

Also regarding document ready, you can use AnyMod.ready if you want some JS outside of your mod to run after the mods have loaded :+1:

https://guide.anymod.com/guide/global-methods.html#anymod-ready

Thanks for the hint where to find the JS-Assets!
I never yet stumbled upon that indication :wink:
Goos to know. And might indeed be good to display those assets close to the JS ans CSS Tabs .

Thank you for the little reminder regarding AnyMod.ready, just what I needed at this moment :wink:

PS: I inserted the below script at the bottom of my HTML Body Tag. As you can see I still had to add an additional setTimeout for the AnyMod.ready function to run at a time when the dom has finished rendering. Without the setTimeout I cannot successfully reference towards AnyMod.ready, as it is not defined at that time.

(Uncaught ReferenceError)

Could you provide me with another hint to avoid the setTimeout?

<script type="text/javascript">  
setTimeout(function(){   
    AnyMod.ready(function () { 
        console.log('Hello world!') ;    
    })  
}, 5000); 
</script>

Are you able to share the page (or the code for it)? You shouldn’t need that setTimeout.

My only guess for now would be that the script tag in the head uses Anymod (old capitalization), while I suggested AnyMod (capitalized M, which we switched to a few months ago). If they are different then it might cause AnyMod.ready to not be available.

Stefan, I looked at the link you emailed me and it does appear to be a capitalization issue.

Your script in the head has

<script id="Anymod-script">
  ...
  ("Anymod","...","https://cdn.anymod.com/v2",window,document,"script",{...})
</script>

If you change it to

<script id="AnyMod-script">
  ...
  ("AnyMod","...","https://cdn.anymod.com/v2",window,document,"script",{...})
</script>

It should work. Alternatively, you could use Anymod.ready – as long as they match!

1 Like

cool to see the JS-Indications inside of the Mod-editor Tabs !! Thanks :wink:

Also Thanky for that capitalization Hint. Will implement that on Monday

Okay

anymod.ready

started to work once they matched

Thank you Tyler

1 Like

Great! :partying_face:

1 Like