7 posts
  • Has been part of the Envato Community for over 1 year
  • Located in Asia/Pacific Region
  • Sells items exclusively on Envato Market
giring says

How I can use a custom .js file or JQuery in my theme for themeforest? is this good idea? : if (!is_admin()) add_action(“wp_enqueue_scripts”, “my_jquery_enqueue”, 11); function my_jquery_enqueue() { wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “) .”, false, null); wp_enqueue_script(‘jquery’); }

280 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
PrimaThemes says

Please read this, http://support.envato.com/index.php?/Knowledgebase/Article/View/472

3. Themes will be required to use whichever version of jQuery ships with the current version of WordPress.

4. Authors are not allowed to deregister the default version of jQuery and load another one.

7 posts
  • Has been part of the Envato Community for over 1 year
  • Located in Asia/Pacific Region
  • Sells items exclusively on Envato Market
giring says

Please read this, http://support.envato.com/index.php?/Knowledgebase/Article/View/472
3. Themes will be required to use whichever version of jQuery ships with the current version of WordPress. 4. Authors are not allowed to deregister the default version of jQuery and load another one.

thanks Prima I Read it But How I Do This : 3. Themes will be required to use whichever version of jQuery ships with the current version of WordPress.

280 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
PrimaThemes says
do not use
wp_deregister_script('jquery'); 
wp_register_script('jquery', 'your custom jquery');
wp_enqueue_script('jquery'); 

always use

wp_enqueue_script('jquery');

it will automatically load the default jquery on WordPress (except a plugin override it)

7 posts
  • Has been part of the Envato Community for over 1 year
  • Located in Asia/Pacific Region
  • Sells items exclusively on Envato Market
giring says

ok .then I use “wp_enqueue_script(‘jquery’); “ for jQuery.

for other .js file I can use “wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, ‘your custom jquery’); wp_enqueue_script(‘jquery’); “?

280 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
PrimaThemes says

for other .js file I can use … ?

what do you mean by other .js file here?

7 posts
  • Has been part of the Envato Community for over 1 year
  • Located in Asia/Pacific Region
  • Sells items exclusively on Envato Market
giring says

some times i read my functions in .js file or maybe use other .js file for example a .js file of a slideshow

41 posts
  • Has collected 1+ items on Envato Market
  • Located in United Kingdom
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 1 year
Makins says

Usually your functions.php would contain something like this to register a slider:

wp_register_script( 'slider', get_template_directory_uri() .  '/js/slider.js' );

wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'slider' );

or, you can use this, which has the dependency jQuery so you don’t need to enqueue it separately.

wp_register_script( 'slider', get_template_directory_uri() .  '/js/slider.js', array( 'jquery' ) );

wp_enqueue_script( 'slider' );

Finally in the simplest form, you can just use this:

wp_enqueue_script( 'slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ) );
by
by
by
by
by
by