Skip to content
This repository was archived by the owner on May 15, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ With **Reloadr**, you can tell the browsers which files are important enough to
## Client-Side Assets

Just include the following in your web application's <HEAD> tag:

<script src="/reloadr.js"></script>
<script>
// quick, client-side-only syntax
Reloadr.go([
'/js/my_javascript_file.js',
'/css/my_css_file.css'
]);
</script>
```jsx
<script src="/reloadr.js"></script>
<script>
// quick, client-side-only syntax
Reloadr.go([
'/js/my_javascript_file.js',
'/css/my_css_file.css'
]);
</script>
```

By default, the script will poll each of the specified files every two seconds. The If-Modified-Since HTTP header is used to minimize traffic and request size, so if your file has not been updated since the last time it was checked, it won't be transferred. If your file *has* been updated, the browser then will reload the entire page, which is probably what you want if you've changed something and want to see the evidence thereof.

Expand All @@ -28,27 +29,27 @@ By default, the script will poll each of the specified files every two seconds.
Not everyone works on client-side code all the time (myself included). Since your PHP files aren't directly accessible via HTTP, you can use the included reloadr.php file to aggregate the modification dates of your PHP files. Just put it somewhere accessible via HTTP, and if it's not at the top level of your site, tell Reloadr where it lives.

If you want to limit polling to, say, every 10 seconds, you'll need to pass that value (in milliseconds) as the 'frequency' option, as shown below in the full syntax:

<script>
// full, awesome syntax
Reloadr.go({
client: [
'/js/my_javascript_file.js',
'/css/my_css_file.css'
],
server: [
'*.php',
'tests/*.php'
],
path: '/include/reloadr.php',
frequency: 10000
});
</script>

```jsx
<script>
// full, awesome syntax
Reloadr.go({
client: [
'/js/my_javascript_file.js',
'/css/my_css_file.css'
],
server: [
'*.php',
'tests/*.php'
],
path: '/include/reloadr.php',
frequency: 10000
});
</script>
```
All options are, um, optional, but Reloadr won't actually *do* anything if you don't pass it a 'client' or 'server' array.

## Potential Future Features

This is kind of a quick and dirty hack. I'd like to add some features to make usage easier, but still keep it simple. Here are some ideas:

- Scan the document's HEAD to find CSS and JS urls to poll.
- Scan the document's HEAD to find CSS and JS urls to poll.