Sharepoint - Javascript not working when page loads relatively

You are noticing the URL with _layouts/15/start.aspx because the new feature Minimal Download Strategy is activated on your site.

To know more on how it works you can refer the below links

Introduction to MDS

What is start.aspx in SP 2013

If you don't want _layouts/15/start.aspx to be a part of your URL you need to deactivate Minimal Download Strategy feature available under Site Actions -> Manage Site Features

Note: Minimal Download Strategy is a new framework which is been written to increase the performance of the SharePoint site.

Source: Removing _layouts/15/start.aspx# from the URL on the address bar

UPDATE

As per comments from @wjervis, as an alternative to not disabling MDS functionality you can use RegisterModuleInit() method.

Ref: Register CSR Override on MDS enabled SP2013 site


You can disable the Minimal download strategy feature for the site, located under site settings > Manage site features.

That's what adding the extra string to your URL. ("/_layouts/15/start.aspx#").

Tags: