Title: Failed to execute &#8216;insertRule&#8217; on &#8216;CSSStyleSheet&#8217;: Cannot access StyleSheet
Last modified: October 3, 2018

---

# Failed to execute ‘insertRule’ on ‘CSSStyleSheet’: Cannot access StyleSheet

 *  Resolved [ColinD](https://wordpress.org/support/users/colind/)
 * (@colind)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/)
 * Our site is hosted on WP Engine and autoptimize worked as expected on dev and
   staging but when I activated it on production (with WP Engine caching and CDN)
   I got the following error in the console:
    Failed to execute ‘insertRule’ on ‘
   CSSStyleSheet’: Cannot access StyleSheet to insertRule Unchecking “optimize CSS
   Code” eliminates the error.
 * Any advice on how to further diagnose and correct the issue would be greatly 
   appreciated.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffailed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10748357)
 * in what browser do you get that error/ warning ColinD? and what are/ were your
   CSS optimization settings?
 *  Thread Starter [ColinD](https://wordpress.org/support/users/colind/)
 * (@colind)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10750398)
 * Chrome 69, Mac OS Mojave
 * I played with all the settings options before posting. If I check “Optimize CSS”
   on the first tab and leave everything as-is on the extra tab (google fonts: leave
   as is, optimize images: unchecked, remove emojis: unchecked, remove query string:
   unchecked) The error is present. If I try any of the extras it doesn’t change
   the error.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10750454)
 * OK, instead of diving in to settings; I’m pretty sure you have a staging site,
   no? can we enable CSS opt. there so we (I) can see what happens?
 *  Thread Starter [ColinD](https://wordpress.org/support/users/colind/)
 * (@colind)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10750554)
 * Sure. It works as expected on staging and dev. It’s on WP Engine hosting. My 
   guess is that it is somehow related to the WP Engine production environment’s
   cache and/or CDN. How can I share access info to the staging site with you?
 * Thanks for you assistance
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10750572)
 * you can mail me at futtta-at-gmail-dot-com 🙂
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10750871)
 * OK, good and bad news;
    -> the bad is that i don’t know why this would not work
   on the live site while it does work on dev/stating (Autoptimize does not use `
   insertRule`) -> there are multiple references to this JS error and the consensus
   seems to be it is better to have JS add a new stylesheet instead of adding rules
   to existing ones (see for example [https://github.com/sampotts/rangetouch/issues/12](https://github.com/sampotts/rangetouch/issues/12))-
   > the good is that I was able to find the (js-)code that is doing the `insertRule`;
   it’s in `wp-content/themes/userzoom2017/js/scripts.js`, so you might want your
   devs to look into that
 * hope this helps,
    frank
 *  Thread Starter [ColinD](https://wordpress.org/support/users/colind/)
 * (@colind)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10753927)
 * Thanks so much for digging into this for me. I’ve fixed up my code.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10754107)
 * you’re welcome Colin, feel free to [leave a review of the plugin and support here](https://wordpress.org/support/plugin/autoptimize/reviews/#new-post)!
   🙂
 * enjoy the weekend!
    frank

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Failed to execute ‘insertRule’ on ‘CSSStyleSheet’: Cannot access StyleSheet’
is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/failed-to-execute-insertrule-on-cssstylesheet-cannot-access-stylesheet/#post-10754107)
 * Status: resolved