Script not loaded?

Hello there:
i got the following stange problem:
on my page: http://tiefim.weisswald.ski/?page_id=292
i want to have a map using java script displayed.
I use x pro and ill ad the line

“script type=“text/javascript” src=“gpx/GM_Utils/GPX2GM.js”>/script>” (< not shown here)

into the “element” content area.
now i open the page in my brwoser (google chrome) and sometimes the script will be loaded (and displayed in the sourcecode) and sometime the script wont be loaded. in the second (bad)case, ill take a look into the source code and the line “script type=“text/javascript” src=“gpx/GM_Utils/GPX2GM.js”>/script>” is just not there in the content area… other stuff ill put into the content area is still there… so it is just the script which is randomly loaded on chrome and not loaded at all in IE and Firefox…
any suggestions?

Hi There,

Thanks for writing in! To load external Javascript, follow the example below and add it into your child theme’s functions.php file.

add_action( 'wp_footer', 'my_custom_script', 10 );

function my_custom_script(){
      echo '<script src="example.com/js/script.js"></script>';
}

Hope that helps.

hey thanks =)
is there a more explizit step by step tutorial for that? that would be really great… otherwise… ill have to try the hard way =) which i would do… if i had to :wink:

Hi there,

Please refer to this article (https://calderaforms.com/2016/11/how-to-load-custom-javascript-in-wordpress/) it has mentioned clearly how to add custom JS.

Thanks

THanks… i am getting closer! it works in chrome…
on firefox, the map appears for an blink of an eye and than disappears again… any ideas why that is?
e g here: http://tiefim.weisswald.ski/?page_id=298

Hello There,

Thanks for updating in! I can confirm that in Chrome and Firefox, the map just blinks away and disappear. Could you please replace the content area and use raw content element instead?

Please let us know how it goes.

It is working =)

hooray!
thanks for your support!
I dont know why (and thats what i dont like about it, I always got an doubtful feeling using stuff i dont understand) but it works!
Thans so much!
Hannes

We are glad that it works!

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.