question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to load css link into the head tag?

See original GitHub issue

Hello, First of all, thanks for contributing such an amazing js framework. I am very new to grapesjs. And github too.

canvas: {
    scripts: ['https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js']
  }

https://github.com/artf/grapesjs/wiki/Components-&-JS#template-related According to grapesjs wiki, I load js links inside the canvas as the above codes and it works fine.

But when I try with css links like this, it doesn’t work.

canvas: {
      links : ['https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'] 
  }

Some people here suggest to add those CSS links directly under the id=“gjs”. I did it but what happen is if I clean the canvas, it also clean my css links and CSS doesn’t work anymore. My question is how can I load CSS link into the head tag?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
artfcommented, Oct 23, 2017

You were almost there 😃

canvas: {
    styles: ['https://...'] 
}
1reaction
coder-strangecommented, Nov 19, 2018

You have to include separately while rendering, it won’t come in getHtml() or anything.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add CSS
To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property. Example. Inline styles...
Read more >
External CSS Stylesheets – How to Link CSS to HTML and ...
The first of the two indispensable attributes is the rel attribute. You will use this attribute to tell the browser what the relationship...
Read more >
How to Link CSS to HTML Files in Web Development
In order to link HTML to CSS in your HTML file, you need to use link tags with the right attributes. Remember that,...
Read more >
The External Resource Link element - HTML - MDN Web Docs
For example, the stylesheet link type is body-ok, and therefore <link rel="stylesheet"> is permitted in the body. However, this isn't a good ...
Read more >
jquery - Load CSS file into head section or into HTML ...
Not sure how HTML compliant this is, but you can include a link within your body tag and still have it reference the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found