How to add custom JS

I don’t know why after including custom JS in scripts.php, it doesn’t loading the file.

How to do it?

Have you searched? Seems like this has been addressed quite a bit.

If you don’t find an existing thread that helps solve your issue then please paste your problematic code along with any debug/error messages or a more specific description of the unexpected behavior.

Yes. I tried putting my JS code to _main.js

var scr_height = $(window).height();
var scr_half = scr_height / 2;
var inner_height = ($('.home_inner').height() / 2);
var inner_top = scr_half - inner_height;
$('.home_inner').css({'marginTop':inner_top });

inside this code

var Roots = { 
common: {
init: function() {

…and what is happening?

nothing happens. even if I put an alert script it doesn’t working

Are you running Grunt?

no. how to run that?

You really should work your way through the Roots Theme documentation to find out how all of these pieces work together and what you need to do in order to setup your dev environment.

1 Like