• It will be great if there is some option in plugin settings, where we can set on which pages or posts this plugin will load its styles and scripts.

    Currently all plugin CSS/Js files are loaded on everywhere (for example on homepage mostly we don’t need it), which impacts performance/speed. There should options for this, so we can load this plugins styles and scripts on specific page, for example on post detail pages only.

Viewing 1 replies (of 1 total)
  • Thread Starter Muhammad Ayoub

    (@mohammadayoub96)

    I have directly edited plugin files and added custom, its working fine.

    php
    if (is_single()) {
    
      // HCB style
      wp_enqueue_style('hcb-style', LOOS_HCB_URL . 'build/css/hcb_style.css', [], LOOS_HCB_VERSION);
    
      // Coloring style
      wp_enqueue_style('hcb-coloring', LOOS_HCB::$coloring_css_url, ['hcb-style'], LOOS_HCB_VERSION);
    
      // Inline Style
      wp_add_inline_style('hcb-style', LOOS_HCB_Scripts::get_inline_style());
    
      // clipboard.js
      $is_show_copy = LOOS_HCB::$settings['show_copy'];
      if ($is_show_copy) {
        wp_enqueue_script('clipboard');
      }
    
      // Prism.js
      wp_enqueue_script('hcb-prism', LOOS_HCB::$prism_js_url, [], LOOS_HCB_VERSION, true);
      // wp_add_inline_script( 'hcb-prism', 'window.Prism = window.Prism || {}; Prism.manual = true;', 'before' );
    
      // HCB script
      wp_enqueue_script('hcb-script', LOOS_HCB_URL . 'build/js/hcb_script.js', ['hcb-prism'], LOOS_HCB_VERSION, true);
    
      // Global variables to pass to the script
      wp_localize_script('hcb-script', 'hcbVars', [
        'showCopy' => $is_show_copy,
      ]);
    }
    
Viewing 1 replies (of 1 total)
  • The topic ‘Load this plugins styles and scripts on specific page’ is closed to new replies.