Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jade adds empty `style` element to `head`

I'm using Jade as a templating engine for my Express powered node.js application. Maybe it's late in night, but I can't figure out where empty style element inserted in resulting HTML.

Live example: http://quotation-mark.herokuapp.com/ (noticed that <style type="text/css"></style> at the very end of head?)


Express' templates setup:
app.set('views', settings.projectDir + '/views');
app.set('view engine', 'jade');
app.set('view options', {layout: false});


layout.jade
!!!html

include /helpers/css.jade

html(lang='ru')
  head
    meta(http-equiv='content-type', content='text/html; charset=utf-8')
    noscript
      meta(http-equiv="refresh", content="0; url=/noscript")

    title= title

    block css
      mixin css('/css/bootstrap/bootstrap.css')


  body
    block content


index.jade
extends layout

append content
  h1= title
  p Добро пожаловать в #{title}.


I've checked couple of times but everything seems to be okay (code, templates, validators). Not a clue… Is it supposed to happen? Am I mistaken somewhere?

Even if there is no head in template itself, there is one in browser (which is Chrome 19.0.1084.53), maybe browser adds something? Simple HTML page doesn't have it though:

<!DOCTYPE html>

<html>

<head>
<title>Test</title>
<style>h1{color:red;}</style>
</head>

<body>
<h1>Hi!</h1>
</body>

</html>
like image 236
Aleksei Zabrodskii Avatar asked Nov 29 '25 02:11

Aleksei Zabrodskii


1 Answers

The HTML generated by your server doesn't actually have an empty <style> block in it.

<!DOCTYPE html><html lang="ru">
<head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 <noscript><meta http-equiv="refresh" content="0; url=/noscript"></noscript>
 <title>«Кавычки»</title>
 <link rel="stylesheet" href="/css/style.css">
</head>
<body>
  <h1>«Кавычки»</h1><p>Добро пожаловать в «Кавычки».</p>
</body>
</html>

Are you using any browser extensions like AdBlock? When AdBlock is turned on, I see that empty style block in every page I visit. Disabling the extension makes it go away.

like image 67
jimr Avatar answered Dec 01 '25 12:12

jimr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!