Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where the custom Javascript can be inserted? #86

Closed
lukexiki opened this issue Jun 17, 2015 · 9 comments
Closed

Where the custom Javascript can be inserted? #86

lukexiki opened this issue Jun 17, 2015 · 9 comments

Comments

@lukexiki
Copy link

Hi Jeremy,

Well done to the latest version of JointsWP, it's awesome!

One little thing, I'm a little lost as to where I go from here. Where can I insert my custom javascripts? Before I used to input these in Scripts.js in the section (// add all your scripts here). Now in the new version I tried to insert them in the scripts.js but it does not work. Since I'm a newbie, do you have a solution to my dilemma please?

Please let me know,

Thanks a lot,
Luke

@OmniaAgency
Copy link

Luke,

You can place your own javascript files anywhere in the theme and then enqueue them in assets/functions/enqueue-scripts.php.

@scarfeyTIC
Copy link

I too seem to be having the same problem - I've even tried the above suggestion of setting my custom script to enqueue but nothing is working.

@JeremyEnglert
Copy link
Owner

@lukexiki, the theme enqueues from the minified JS file. If you're making changes in the non-minified file, be sure to enqueue that instead.

Although you don't have to use Gulp, the new structure is setup to be used with Gulp. Any JS files you put into the assets/js/site folder will be concatenated and minified into the assets/js/min//scripts.min.js file.

If you don't want to use Gulp/Grunt, just enqueue the non-minified file.

@JeremyEnglert
Copy link
Owner

@scarfeyTIC, if you aren't able to enqueue any scripts, it sounds like there may be a bigger issue. Do you have a link I can check out?

@scarfeyTIC
Copy link

Thanks for the reply Jeremy.

I'm still trying to get my head around the new layout for the JS files so it's obviously something I'm doing wrong. I've been working on this tester site:

http://wyp.pixeltester.net/

I'm using codekit to compile the JS and I think it's outputting in the wrong way. I've been making my script edits in the script.js file outside of the min folder, presuming that it would minify into the script.min.js.

At present I'm just trying to do a simple alert on document.ready to get the files working.

@JeremyEnglert
Copy link
Owner

Here is the JS file your theme is calling:
http://wyp.pixeltester.net/wp-content/themes/west-yorkshire-playhouse/assets/js/min/scripts.min.js?ver=4.2.2

It looks like you want to be calling this file instead:
http://wyp.pixeltester.net/wp-content/themes/west-yorkshire-playhouse/assets/js/min/scripts.js?ver=4.2.2

Go into your assets/functions/enqueue-scripts.php and check out line #20.

Remove the .min from the file name and you should be good to go.

I'll most likely update the theme to call the non-minified file by default. This should help cut back on the confusion.

@lukexiki
Copy link
Author

Hi,

Thanks a lot for your replies.

I have managed to make this work, all you need is to update enqueue-scripts.php to load the proper js you are working on and make sure that the custom code is before jQuery(document).foundation();

thanks a lot Jeremy and OmniaAgency

regards
Luke

@scarfeyTIC
Copy link

Morning Jeremy.

Thanks for looking in to this for me. For anybody else struggling with this the above suggestion from Jeremy works.

Thanks for the help.

@JeremyEnglert
Copy link
Owner

The theme now calls the non-minified script by default.

However, I still highly recommend minifying your JS before launching a site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants