Closed marvinrabe closed 4 years ago
@marvinrabe
Thank you for the issue @marvinrabe, could you please share your gatsby-config.js file so I can better understand how this would happen?
Going to leave this issue open a bit longer but I have not been able to reproduce this myself. Unless @marvinrabe can provide a reproduction of the issue soon then I will have to close this.
This happens when using a gatsby source plugin for fetching remote data.
This can be seen with: https://github.com/TryGhost/gatsby-starter-ghost
This is also an issue for me.
What i originally did (before I found this plugin) was i created a gatsby-ssr.js like this:
const get = require('lodash/get');
function filterJavascriptItems(item) {
const href = get(item, 'props.href');
const src = get(item, 'props.src');
const expression = new RegExp('.(js|json)$');
if (href && expression.exec(href)) {
return false;
}
if (src && expression.exec(src)) {
return false;
}
return true;
}
exports.onPreRenderHTML = ({
getHeadComponents,
replaceHeadComponents,
getPostBodyComponents,
replacePostBodyComponents
}) => {
if (process.env.NODE_ENV === 'production') {
const filteredHeadComponents = getHeadComponents().filter(
filterJavascriptItems
);
replaceHeadComponents(filteredHeadComponents);
const filteredPostBodyComponents = getPostBodyComponents().filter(
filterJavascriptItems
);
replacePostBodyComponents(filteredPostBodyComponents);
}
};
This approach is based on @jordanoverbye https://github.com/jordanoverbye/gatsby-plugin-no-js
@marvinrabe @mathiasha
This is now fixed with v2.0.5
HTML still contains:
This has no purpose without JavaScript but still gets downloaded.