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

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:

Read More
<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.

Related posts

Leave a Reply

4 comments

  1. 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>
    
  2. 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).

  3. 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.