Why is WordPress placing "text/rocketscript" instead of "text/javascript" when using wp_register_script()?

Wordpress

Wordpress Problem Overview


I inserted the following code in a WordPress plugin:

   wp_deregister_script('jquery');
   wp_register_script('jquery', "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js");
   wp_enqueue_script('jquery');

The following is echoed to the browser:

<script type='text/rocketscript' data-rocketsrc='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js?ver=3.3.1'></script>

Instead of:

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>

I don't know what is happening. Perhaps wp_register_script() is supposed to work in this way. I also tested if any jQuery code worked on the client side but it didn't.

Wordpress Solutions


Solution 1 - Wordpress

It is easy to fix.

You must change the following tag: <script type="text/javascript"></script>

add: data-cfasync="false"

example:

<script data-cfasync="false" type="text/javascript"></script>

Solution 2 - Wordpress

Probably one of wordpress plugins is using CloudFlare.

https://support.cloudflare.com/hc/en-us/articles/200168056-What-does-Rocket-Loader-do-

Try disabling all the plugins and re-enabling them one by one to find out which one is causing this issue. It's not a problem actually.

Solution 3 - Wordpress

Rocket Loader is not included in any WordPress plugins. You would have to disable Rocket Loader by going to: settings->CloudFlare settings (Performance Settings)->Rocket Loader->Toggle Off (this feature is optional and has to be turned on).

Solution 4 - Wordpress

I was facing this issue with

WP Rocket plugin which was adding type='text/rocketscript' to the script tags.

Fixed it by adding

data-cfasync="false"

to the script tags.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTabrez AhmedView Question on Stackoverflow
Solution 1 - WordpressFrankView Answer on Stackoverflow
Solution 2 - WordpressEmir AkaydınView Answer on Stackoverflow
Solution 3 - WordpressDamon BillianView Answer on Stackoverflow
Solution 4 - WordpressAboobacker PView Answer on Stackoverflow