Comments (5)
If that user agent check is good enough for core, I imagine it's good enough for the theme. If it's working as is, I'm not sure it makes sense to invest in a different solution.
from twentytwentyone.
Need is a strong word...
As I've said before, the fact that we "support" IE doesn't mean that IE should have the same styles as other browsers. As long as the content is readable in IE I don't think we need to do something.
from twentytwentyone.
Considering the small percentage of users still on IE (<2% last I checked), I think conditionally loading IE styles based on the WordPress global / user agent sniffing is still the best approach.
Are there other methods that should be considered?
Conditional comments used to work, but not for IE10+.
The other approach could be feature detection, but I'm not sure it's allowed to load the theme's stylesheet via client side JS?
from twentytwentyone.
I agree with @kjellr
Though the $is_IE
global is far from perfect (has lots issues with aggressive caching plugins), for the sake of simplicity it's fine to use it here.
The other approach could be feature detection, but I'm not sure it's allowed to load the theme's stylesheet via client side JS?
It's allowed and works fine. Surprisingly it's also extremely easy to do... We can simply add this in functions.php
:
add_action( 'wp_footer', function() {
?>
<script>
if ( ! window.CSS || ! CSS.supports( 'color', 'var(--fake-var)' ) ) {
var style = document.createElement( 'link' );
style.rel = 'stylesheet';
style.type = 'text/css';
style.href = '<?php echo esc_url( get_theme_file_uri( 'assets/css/ie.css' ) ); ?>';
document.head.append( style );
}
</script>
<?php
} );
The reason I'm suggesting it be added inline is because there's no reason to enqueue yet another script file - especially when it's that small and we need to get the URL via PHP, gzipped that's < 200 bytes.
It's equally possible to add it using wp_enqueue_script()
and use wp_localize_script()
to pass the file-url as a var from there, but it just adds useless overhead and will force the browser to download yet another asset for the 1-2% of users that will need it.
from twentytwentyone.
But do we need and or want to support IE?
from twentytwentyone.
Related Issues (20)
- Some elements arenβt visible on focus when the body background color is set to white HOT 3
- Spacing issue inside the editor HOT 1
- Impossible to display a button on dark background as the colors are overridden by the theme on hover HOT 2
- Post pagination current item style
- With an off-white page background, text focus styles are hard to see HOT 3
- Display captions below featured images HOT 1
- Bug: Cursor is not visible when inserting a new button. HOT 5
- Editor: With Dark Mode enabled, buttons are only white if the selected body background is the default color HOT 1
- Delete sass/02-tools/extends.scss
- Changing image block size does not change caption placement. HOT 2
- The scroll bar of the right sidebar is appearing and dissipating when the height of a browser window between 775-787 px HOT 2
- Task: Report issues with Gutenberg or trac labels upstream HOT 2
- Use :focus-visible instead of :focus to remove undesirable focus styles for mouse clicking HOT 2
- Submenu toggle is too close to the menu item text
- JavaScript error when the responsive menu is toggled
- Buttons placed in a block that has the grey palette color as background are sometimes invisible HOT 4
- Bug: gradient presets shows linear input selections when radial is selected
- The embed figcaption is the wrong text color
- Search block: When the button is inside, the input field has no visible focus indicator
- NEW ISSUES SHOULD BE CREATED ON TRAC
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twentytwentyone.