Say you have an external stylesheet (<link>
), followed by a <script>
. Is the external stylesheet always applied before the <script>
executes, so that getComputedStyle
always respects the external stylesheet's rules?
Or are browsers allowed to run JavaScript before earlier stylesheets have been applied?
Example:
<!doctype html>
<html>
<head>
<link href="/my-stylesheet.css" rel="stylesheet" />
</head>
<body>
<div id="foo"></div>
<script>
window.getComputedStyle(document.getElementById('foo')).width
// => "200px" due to stylesheet - is this reliable?
</script>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire