2

we (my son and me) modified a script - '/js/sticky-menu.js' - and it only works when Cloudflare 'Rocket Loader' is off.

Following the tutorial for Rocket Loader I tried to exclude the script by adding this code into the header (using theme settings of Genesis):

<script data-cfasync="false" src="/javascript.js"></script>      

I modified the code to

<script data-cfasync="false" src="/js/sticky-menu.js"></script>

After saving the code I got this warning-message:

403 Forbidden

A potentially unsafe operation has been detected in your request to this site.

Also using the complete path of the script doesn't work.

Here is the URL of my website.

Have you a solution for this problem?

kind regards, Rainer Brumshagen

2

Solution:

Because the theme JavaScript is not in:

/js/sticky-menu.js

Rather, it's in your theme folder (as your theme name is lifestyle-pro, as found from your site's HTML):

/wp-content/themes/lifestyle-pro/js/sticky-menu.js

So your <script> CODE should be:

<script data-cfasync="false" src="/wp-content/themes/lifestyle-pro/js/sticky-menu.js"></script>

Bonus:

This can be made better with the use of the WordPress function get_stylesheet_directory_uri(). In that case, your CODE will be:

<script data-cfasync="false" src="<?php echo get_stylesheet_directory_uri(); ?>/js/sticky-menu.js"></script>

An even better method is to use wp_enqueue_script() function in combination with wp_enqueue_scripts filter hook, as described in this WordPress document.

| improve this answer | |
  • 1
    Yes, thank you for your answer. I agree with you to take the whole wp-path or even the Bonus-version. – Rainer Brumshagen Feb 5 '17 at 10:41
0

In this case the solution is

  1. De-activation of the plugin "wordfence", that didn't allow to write into the head-section.
  2. Changing a code-snippet in the 'functions.php' to get the 'sticky-menu.js' working. After this changing the script needn't put in into the head-section. I got the correct code-snippet for the 'functions.php' from this tutorial.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.