[Rocket Loader] Uncaught ReferenceError: on is not defined

Hello there! I’m a new user, just getting started with Cloudflare on my website.

When viewing my website with the Developer Tools open (cache disabled, in an Incognito window), I get an error message in the Console related to Rocket Loader:

    VM364:5 Uncaught ReferenceError: on is not defined
        at <anonymous>:5:32
        at t.activateScript (rocket-loader.min.js:1)
        at rocket-loader.min.js:1
        at t.run (rocket-loader.min.js:1)
        at rocket-loader.min.js:1
        at HTMLScriptElement.<anonymous> (rocket-loader.min.js:1)

What is the issue here? Is it a configuration error on my part, a compatibility issue, or something else entirely?

My website is available here, in case someone would like to see for themselves what could be causing this.

I’ve seen similar reports in the past from other users, which were ultimately dropped/unanswered, so here I am posting about this.

As far as I can tell this is because of the following code on your site

var e = document.getElementsByTagName('body')[0];
if(e)
{
	e.setAttribute('unselectable',on);
}

Try to disable Rocket Loader and check if it fixes the issue.

On the other hand, the attribute in question is not really supported any longer, so it might be the best choice to simply remove these five lines.

1 Like

Hey there! Thanks a lot for the help.

Disabling Rocket Loader has indeed removed the error from the console.

However, I’m interested in looking into your suggestion to remove that part of the code from the page - what is that attribute referring to, and how could I go about trimming it from the site’s code?

I’m not a developer of any kind, so I’m taking in all the advice I can to get my website to be as sleek as possible!

EDIT: from what I could find with a quick Googling, it seems to refer to the WP Content Copy Protection plugin, which is useful against low-skill attempts to copy my works from my webpage.

I have tried disabling it, enabling Rocket Loader once more, empty my website’s cache, and the error is now gone. So I guess that was the origin of the issue.

How could I replace this with a tidier code?

I am afraid that would be a question rather for StackExchange and the like. But your observation appears to be correct, that seems to be some semi-useful attempt to prevent visitors from copying text.

1 Like

Ok, I seem to have found a solution, I’m going to share it here for future reference.

As I had guessed thanks to sandro’s help, the issue was borne of an incompatibility between Rocket Loader and the WP Content Copy Protection plugin.

So all I did was removing said plugin, and exchanging it with another plugin - No Right Click Images Plugin. This appears to work well with Rocket Loader, and my console is now clear of javascript errors related to it.

At the time of writing, the plugin hasn’t been updated in 9 months, and its compatibility with the current version of WordPress (5.3.2) isn’t guaranteed; however, it seems to work stably, and actually prevents right-clicking on images while leaving it enabled for links and text (useful for keeping your blogs easily quotable and linkable while protecting images from low-skill appropriation.

Again, thanks to sandro here, and I hope this post is useful for the community in the future!

This topic was automatically closed after 30 days. New replies are no longer allowed.