-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
HTML comments? #3105
Comments
There's no need to wrap polyfill.io's script in a conditional due to the nature of the service: it already detects and sends only the polyfills your user's browser needs. |
@arianon Ah I missed that thanks for the advising. |
I think this issue is still important even though maybe not for polyfill.io... any way to include something like respond.js or html5shiv.js conditionally? |
Hi there, We need html comments in order to add css that provide fallbacks for IE11 which does not have css grids. Is it possible to add some functionality in the next/head component that allows for outputting plain html comments? Example of what we are trying to do: import React from 'react';
import PropTypes from 'prop-types';
import Head from 'next/head';
import stylesheet from '../style/main.scss';
const HeadComponent = ({
title, description, image, url, ogp,
}) => (
<Head>
<meta charSet="utf-8" />
<meta httpEquiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>{title}</title>
<meta name="description" content={description} />
<meta property="og:url" content={ogp.url ? ogp.url : url} />
<meta property="og:type" content="website" />
<meta property="og:title" content={ogp.title ? ogp.title : title} />
<meta property="og:image" content={ogp.image ? ogp.image : image} />
<meta property="og:description" content={ogp.description ? ogp.description : description} />
<meta property="og:site_name" content="" />
<meta property="og:locale" content="en_US" />
{/* Twitter will reuse OGP declarations for description and image */}
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="" />
<link rel="icon" type="image/png" href="/static/favicon.png" />
<style dangerouslySetInnerHTML={{ __html: stylesheet }} />
<div
dangerouslySetInnerHTML={{
__html: `<!--[if IE]>
<style>
.c-longform-grid {
max-width: 620px !important;
}
</style>
<![endif]-->`,
}}
/>
</Head>
); |
Hello all, I'd like to know how HTML comments can be done in next.
I'm about to use HTML comments with conditions like this to distinguish IE and put some polyfills like this:
Expected Behavior
To resolve this issue, I just followed workaround where I found from the react issue: facebook/react#1035 (comment)
Layout
Head
:Current Behavior
But I ended up with this weird error when I directly add comment text to
Head
:And seems like
dangerouslySetInnerHTML
prop inHead
does not make any changes to output unlike typical dom elements.Context
Any tips to add HTML comments directly to next app?
Your Environment
The text was updated successfully, but these errors were encountered: