Skip to content

Commit 10eaced

Browse files
Merge pull request #24 from mudbugmedia/update-penthouse-1.0
Update penthouse 1.3
2 parents 5574bf6 + 90a8bb9 commit 10eaced

File tree

8 files changed

+220
-644
lines changed

8 files changed

+220
-644
lines changed

README.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,32 @@
22

33
Only load the CSS you need for the initial viewport in Rails!
44

5-
This gem give you the ability to load only the CSS you *need* on an initial page view. This gives you blazin' fast rending as there's no initial network call to grab your application's CSS.
5+
This gem gives you the ability to load only the CSS you *need* on an initial page view. This gives you blazin' fast rending as there's no initial network call to grab your application's CSS.
66

77
This gem assumes that you'll load the rest of the CSS asyncronously. At the moment, the suggested way is to use the [loadcss-rails](https://github.com/michael-misshore/loadcss-rails) gem.
88

99
This gem uses [Penthouse](https://github.com/pocketjoso/penthouse) to generate the critical CSS.
1010

11-
## Upgrading to the Latest Release
11+
## Dependency Requirements for / Upgrading to the Latest Release
1212

13-
Upgrade instructions from each version are included below.
13+
### For 1.0.0 or later
14+
To maintain the latest version of Penthouse, this gem depends on NodeJS and NVM to be installed on the system.
15+
16+
### For 2.0.0 or later
17+
This gem may require additional packages to be installed to run Chrome headless. Per the Penthouse documentation, this may be all you need:
18+
19+
```
20+
sudo apt-get install libnss3
21+
```
22+
23+
However, more packages may need to be installed depending on your OS distribution which can be found via [this answer](https://github.com/GoogleChrome/puppeteer/issues/404#issuecomment-323555784)
1424

1525
## Installation
1626

17-
Add `critical-path-css-rails` to your Gemfile:
27+
After reviewing the dependency requirements, add `critical-path-css-rails` to your Gemfile:
1828

1929
```
20-
gem 'critical-path-css-rails', '~> 1.0.1'
30+
gem 'critical-path-css-rails', '~> 2.3.0'
2131
```
2232

2333
Download and install by running:
@@ -110,9 +120,6 @@ Careful use of these methods allows the developer to generate critical path CSS
110120

111121
A user can use these methods to [dynamically generate critical path CSS](https://gist.github.com/taranda/1597e97ccf24c978b59aef9249666c77) without using the `rake critical_path_css:generate` rake task and without hardcoding the application's routes into `config/critical_path_css.yml`. See [this Gist](https://gist.github.com/taranda/1597e97ccf24c978b59aef9249666c77) for an example of such an implementation.
112122

113-
## Upgrading from version 0.X.X to 1.0.0
114-
To maintain the latest version of Penthouse, this gem now depends on NodeJS and NVM to be installed on the system.
115-
116123
## Upgrading from a version earlier than 0.3.0
117124

118125
The latest version of Critcal Path CSS Rails changes the functionality of the `generate` method. In past versions,
@@ -124,10 +131,10 @@ Developers upgrading from versions prior to 0.3.0 will need to replace `Critical
124131
rails generate critical_path_css:install
125132
```
126133

127-
Answer 'Y' when prompted to overwrite `critical_path_css.rake`. However, overwriting `critical_path_css.yml` is not necessary and not recommended.
134+
Answer 'Y' when prompted to overwrite `critical_path_css.rake`. However, overwriting `critical_path_css.yml` is not recommended nor necessary.
128135

129136

130-
## Testing
137+
## Testing / Development
131138

132139
This gem is to be tested inside of docker/docker-compose. [Combustion](https://github.com/pat/combustion), alongside rspec-rails and capybara, are the primary components for testing. To run the test, you'll need to have [Docker](https://docs.docker.com/engine/installation) installed. Once installed, run the following commands in the gem's root to build, run, and shell into the docker container.
133140

@@ -152,8 +159,6 @@ major version bump = major-level updates to critical-path-css-rails, Penthouse,
152159

153160
## Contributing
154161

155-
Feel free to open an issue ticket if you find something that could be improved. A couple notes:
156-
157-
* If the Penthouse.js script is outdated (i.e. maybe a new version of Penthouse.js was released yesterday), feel free to open an issue and prod us to get that thing updated. However, for security reasons, we won't be accepting pull requests with updated Penthouse.js script.
162+
Feel free to open an issue ticket if you find something that could be improved.
158163

159164
Copyright Mudbug Media and Michael Misshore, released under the MIT License.

docker/ruby/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ FROM ruby:2.5.0
44
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
55
RUN apt-get update && apt-get install -y build-essential libpq-dev nodejs npm
66

7+
# Install Penthouse JS Dependencies
8+
RUN apt-get install -y libpangocairo-1.0-0 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libgconf2-4 libasound2 libatk1.0-0 libgtk-3-0
9+
710
RUN npm cache clean -f
811
RUN npm install -g n
912
RUN n 8.9.3

docker/ruby/startup.dev

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

33
bundle check || bundle install
4+
bundle update critical-path-css-rails
45

56
bundle exec rackup --host 0.0.0.0

lib/critical_path_css/css_fetcher.rb

-5
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ def css_for_route(route)
4444
'renderWaitTime' => 100,
4545
# set to false to load (external) JS (default: true)
4646
'blockJSRequests' => true,
47-
# see `phantomjs --help` for the list of all available options
48-
'phantomJsOptions' => {
49-
'ignore-ssl-errors' => true,
50-
'ssl-protocol' => 'tlsv1'
51-
},
5247
'customPageHeaders' => {
5348
# use if getting compression errors like 'Data corrupted':
5449
'Accept-Encoding' => 'identity'
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module CriticalPathCSS
22
module Rails
3-
VERSION = '1.0.1'.freeze
3+
VERSION = '2.3.0'.freeze
44
end
55
end

0 commit comments

Comments
 (0)