This can happen if you are a Visitor to a publishing enabled site and the master pages are not published.
Action: contact the site administrator, have him go to Design Manager (/_layouts/15/DesignMasterPages.aspx) and check if the master page currently applied to the site is published and approved.
When can this happen ( well other than a designer modifying the master pages and forgetting to publish them) ?
If you import a design package.
The administrator/owner can confirm that a Design Package was imported by going to the master pages gallery and trying to publish for example oslo.master.
If the message "This file may not be moved, deleted, renamed, or otherwise edited." appears, it means the file is blocked by Design Manager
IMPORTANT : Do not remove the design packages from Site Collection Solutions .
http://msdn.microsoft.com/en-us/library/jj862342.aspx : "In SharePoint 2013 you cannot uninstall an imported design package, and you should never attempt to deactivate a design package through the solution gallery. If you do, page layout content types are removed and users may not be able to create subsites."
If you are retrieving content using CSOM and your scripts are also published under _catalogs/masterpage (or in a document library that denies access to the unpublished files to people other than Designers or Owners) you need to publish them as well, otherwise the visitors will not be able to open them and the scripts will not run, so the content will not get aggregated.
Same goes for Css files or images.