Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Accelerated Mobile Pages with Bootstrap

I have a website that uses Bootstrap. Technically, I'm using Bootstrap 4 at the moment. I want to leverage Accelerated Mobile Pages (AMP) in the publicly-facing parts of my page. However, I have several errors that I can't seem to shake. This has me wondering, can I even use Bootstrap with an Accelerated Mobile Page?

Am I even allowed to use JavaScript in Accelerated Mobile Pages? Bootstrap has JavaScript for the hamburger menu on mobile phones. Yet, when I run the validator, I see errors like:

The attribute 'href' in tag 'link rel=stylesheet for fonts' is set to the invalid value 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css'.
The attribute 'rel' in tag 'link rel=' is set to the invalid value 
The tag 'script' is disallowed except in specific forms.

So, back to my question. Is it possible to have a Bootstrap 4 site that uses Accelerated Mobile Pages?

Thanks!

like image 646
user70192 Avatar asked Jun 27 '16 21:06

user70192


People also ask

Can we use bootstrap in AMP pages?

You can use bootstrap css and components with AMP if those components do not rely on bootstrap. js since AMP dosent allow 3rd party JS as of now. Plus, you need to remove ! important wherever it is used in bootstrap css as AMP restricts the use of !

Is bootstrap good for mobile?

Bootstrap is a powerful UI framework. It makes responsive “mobile first” development easier and saves developers valuable time. It solves the problem of having to write an overwhelming amount of repetitive code. Additionally, as an open-source framework, you can use and modify it without having to spend a dime.

What does accelerated mobile pages do?

Accelerated Mobile Pages (AMP) is an open source project created to improve the performance of web pages for mobile devices. The project was spearheaded by Google and Twitter. The technology behind AMP enables lightweight pages that load more quickly for smartphone and tablet users.


1 Answers

Try this bootstrap 4 CSS prepared for AMP project: https://github.com/jupeter/bootstrap/blob/v4-dev/dist/css/bootstrap-amp.min.css

This project is based on orginal bootstrap 4 fork. All components loaded in the CSS file are placed: https://github.com/jupeter/bootstrap/blob/v4-dev/scss/bootstrap-amp.scss

If you need add custom components, you can add in the "scss/bootstrap-amp.scss" file and recompile using:

$ npm run amp-css

Disclosure: As @Filnor notice, it's forked and modified by me.

like image 100
Jupeter Avatar answered Sep 24 '22 15:09

Jupeter