Welcome Guest, Not a member yet? Register   Sign In
Sprinkle - Asset Management Library
#1

[eluser]Edmundas Kondrašovas[/eluser]
Greetings everyone,

I know there are some similar libraries (and very good ones, too!) out there but this was somewhat of a hobby of mine (actually, I was experimenting with this for a project and decided to release it publicly).

Here are the main features:

- Asset definitions
- Asset grouping
- Filters (cssmin, jsmin etc)
- Asset routes (for auto-loading assets depending on the route)
- Caching
- Combining assets
- Asset definitions & routes in YAML or pure PHP files
- Asset baking (process assets via cronjob or terminal/command prompt)

The library is available as a spark: http://getsparks.org/packages/Sprinkle/v.../HEAD/show
GitHub: https://github.com/edmundask/Sprinkle

There may be some bugs or limitations that I don't know about although I tested it in various scenarios. Smile

Let me know if you have any use for it. Also, don't forget to read the wiki to get more information.
#2

[eluser]quasiperfect[/eluser]
hi

is possible to define the order of assets ?

cssfile1,cssfile2 etc
#3

[eluser]Edmundas Kondrašovas[/eluser]
No, there's no such feature in Sprinkle. Personally I never needed to change the order of assets to be loaded on specific pages. Could you provide with an example?
#4

[eluser]quasiperfect[/eluser]
hi
thanks for responding

a example
in my project i have a css file for reset, one for forms, one for buttons etc
some files overwrite the properties defined in other files

or some javascript plugins depend on other files to be loaded first
#5

[eluser]quasiperfect[/eluser]
another problem i tried to output a group with
Code:
<?php echo $this->sprinkle->output('js-libs');?>

and works only if i have defined the group also in asset_routes.php using (:any)

is possible to output some assets without defining in routes ?
#6

[eluser]Edmundas Kondrašovas[/eluser]
Yes, it is possible. See the example below.

Code:
$this->sprinkle->load('jquery');

$scripts = $this->sprinkle->js(
array
(
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js'
));

$this->sprinkle->group('js-scripts', $scripts);
$this->sprinkle->group('js-scripts', 'jquery');

Alternatively, you can avoid calling group() method twice by adding the pre-defined asset name to the $scripts array or passing it in as the second parameter of the group() method.

Code:
$scripts[] = 'jquery';

$this->sprinkle->group('js-scripts', $scripts);

// OR
$this->sprinkle->group('js-scripts', $scripts, array('jquery', 'some-other-pre-defined-asset-name'));

Then you can output the group:

Code:
$this->sprinkle->output('js-scripts');
#7

[eluser]royalgiant[/eluser]
Hi,

First let me say, great library. Easy to use.
I have just ran into some problems though.
Before using the library, my pages were loading in about 60-80ms.
After using the library, they were taking about 5 secs to load.
(ex. By (un)commenting the echo $this->sprinkle->output(); i found this peculiarity)

I'm assuming that by "baking assets" this would fix the problem? However, i followed your baking
tutorial and i appear to get an error. Something to do with the loader, not sure what?

ex.
<p>Unable to connect to your database server using the provided settings.</p>
<p>Filename: /Applications/XAMPP/xamppfiles/htdocs/470repo/projects/main/development/CodeIgniter/third_party/MX/Loader.php</p><p>Line Number: 98</p>

Any ideas on this?
#8

[eluser]Edmundas Kondrašovas[/eluser]
Hi there,

as mentioned in the wiki, the loading times can significantly increase if assets are fetched from remote locations. That's because Sprinkle checks HEADER information to see if the file has been renewed (updated).

This is where baking assets comes into play. In the config file you need to set disable_processing option to TRUE.

As for the error that you're getting, I checked line 98 of that file it I don't see how that's related to Sprinkle. Maybe you have a different version of HMVC you the Loader.php file was modified?

Also, which version of PHP are you running? Make sure your setup meets the requirements.
#9

[eluser]royalgiant[/eluser]
I apologize i don't think it's a problem with your library. I'm running php 5.3.1 and the latest version of CI.
I think it's a problem with the CLI controller. I followed this tutorial http://ellislab.com/codeigniter/user-gui...l/cli.html
and that doesn't provide the proper result as well. Rather it gives the same error as mentioned above.

Could me running a mac make any difference? Sorry, this post might be a bit irrelevant, but i'm just posting
anyways in hopes that u have any idea of what's going on.

Again, thank you for your help and the great library!




Theme © iAndrew 2016 - Forum software by © MyBB