0

My script and stylesheet files have been failing to load in Chrome IOS, and only Chrome IOS. I changing the value of $ver in wp_register_script from a string with a value ("1.0.17") to an empty string, and this caused the problem to clear up. I changed it back, and that caused the problem to happen again, but when I did that process a second time the problem didn't occur, and now I can't reproduce it.

Does anybody know what might be going on with this, and how I can prevent it from happening in the future?

class Queue{
    private $cssVer = "1.0.43";
    // Chrome breaker?
    private $jsVer = "1.0.17";

    function __construct() {
        $this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
        $this->add_actions();
    } 
    public function add_actions(){
        add_action( 'wp_enqueue_scripts',array( $this, 'queue_all' ),20 );
    }
    public function queue_all(){
        $this->queue_scripts();
        $this->queue_styles();
    }
    private function queue_styles(){
        $this->enqueue_all_css();
    }
    private  function queue_scripts(){
        $this->enqueue_custom_js();
    }
    private function enqueue_all_css(){
        wp_register_style('style-label', 
            get_stylesheet_directory_uri().'/folder/filename'.$this->suffix.'.css', 
            null, 
            $this->cssVer, 
            "all"
        );
        wp_enqueue_style( 'style-label',1 );
    }
    private function enqueue_custom_js(){
            wp_register_script('label-js', 
                get_stylesheet_directory_uri().'/folder/file'.$this->suffix.'.js', 
                ['jquery'], 
                $this->jsVer, 
                false
            );
            wp_enqueue_script( 'label-js' );
        }
    }
}
  • Are all scripts and styles failing to load, or just certain scripts that you're adding? If it's the latter you should share the code you're using to do this. – Jacob Peattie May 24 '19 at 15:04
  • Have you tried to flush your Browser cache already? – leymannx May 24 '19 at 15:15
  • I added console.log comments to another, plugin-based script that was using a version, and it also appears to be failing to load (based on the failure of that log to appear in chrome://inspect). It's still failing to load, even after I cleared the cache. – Rebecca May 24 '19 at 15:30

Your Answer

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

Browse other questions tagged or ask your own question.